﻿using AiXiu.BLL;
using AiXiu.IBLL;
using AiXiu.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiXiu.WebSite
{
    /// <summary>
    /// VideoUploadHandler 的摘要说明
    /// </summary>
    public class VideoUploadHandler : IHttpHandler
    {


        public void ProcessRequest(HttpContext context)
        {
            string fileName = HttpUtility.UrlDecode(context.Request.QueryString["filename"]);
            string headline = HttpUtility.UrlDecode(context.Request.QueryString["headline"]);
            if (string.IsNullOrEmpty(headline))
            {
                headline = "短视频";
            }
            string location = HttpUtility.UrlDecode(context.Request.QueryString["location"]);

            TBUsers user= IdentityManager.ReadUser();
            int userId = user.Id;
            IVideoBLL videoBLL = new VideoBLL();
            CreateUploadVideoResult result= videoBLL.ToBeUpload(userId, fileName, headline, location);
            //结果进行json序列化
            string jsonResult= JsonConvert.SerializeObject(result);
            context.Response.ContentType = "text/plain";
            context.Response.Write(jsonResult);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}